package m202311.d01;

/**
 * @author haocongshun
 * @date 2023/11/01 18:43:37
 */

/**
 * 26. 删除有序数组中的重复项
 */
public class Q26 {

    public static void main(String[] args) {
        int[] ints = new int[]{1, 1, 2};
        int i = new Q26().removeDuplicates(ints);
        System.out.println();
    }

    public int removeDuplicates(int[] nums) {
        int p = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] != nums[p]) {
                p++;
                nums[p] = nums[i];
            }
        }
        return p+1;
    }
}
